package org.app.Controller;

import jakarta.annotation.Resource;
import org.app.Entity.ExercisePlan;
import org.app.Entity.Like;
import org.app.Entity.comm.Result;
import org.app.Service.ILikeService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.annotation.RequestScope;

import java.util.List;

@RestController
@RequestMapping("/like")
@CrossOrigin("*")
public class LikeController {
    @Resource
    private ILikeService likeService;

    @PostMapping("/addLike")
    public Result<Integer> createCollection(@RequestBody Like like){
        return likeService.createCollection(like);
    }
    @GetMapping("/getAllLike")
    public Result<List<ExercisePlan>> getAllByCID(@RequestParam("c_id") String c_id){
        return likeService.getAllByCID(c_id);
    }
    @DeleteMapping("/deleteLike")
    public Result<Integer> deleteByPidAndCid(@RequestParam("c_id") String c_id,
                                             @RequestParam("p_id") String p_id){
        return likeService.deleteByPidAndCid(c_id,p_id);
    }
}
